from django.db import models

# Create your models here.
from django.contrib.auth.models import User
from django.utils import timezone



class ArticlePost(models.Model):
    # 文章作者。参数 on_delete 用于指定数据删除的方式
    author = models.ForeignKey(User, on_delete=models.CASCADE)

    title = models.CharField(max_length=200)

    body = models.TextField()

    created = models.DateTimeField(default=timezone.now)

    updated = models.DateTimeField(auto_now=True)

    
    class Meta:
        ordering = ('-created',)
    def __str__(self):
        return self.title
    '''
    class Meta:
        ordering = ('-created',)
        
    def __str__(self):
        return self.title''' 